package com.xiaotu.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


/**
 * 静态资源处理器
 *
 * @author zhangxiao
 * @create 2021-01-13 23:14
 */
@Configuration
@PropertySource({"classpath:config.properties"})
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

    //资源映射路径
    @Value("${file.mapping:\"\"}")
    private String mappingUrl;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(mappingUrl).addResourceLocations(
                "file:" + FileConfig.fileUploadPath);
    }

}
